package com.ld.security.shop.crawler.modules.wo.api;

import com.ld.security.common.core.base.vo.DataVo;
import com.ld.security.common.core.base.vo.EntityVo;
import com.ld.security.common.core.base.vo.SuperVo;
import com.ld.security.common.tomcat.base.api.*;

import com.ld.security.shop.crawler.modules.wo.entity.WoTask;

import com.ld.security.shop.crawler.modules.wo.po.TaskDispatchPo;
import com.ld.security.shop.crawler.modules.wo.service.IWoTaskService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags="任务Api管理")
@RequestMapping("/api/woTask")
public class  WoTaskApi extends  SuperApi<WoTask> {

    @Autowired
    IWoTaskService iWoTaskService;

    @ApiOperation("任务执行调度")
    @RequestMapping(value = "/dispatch",method = RequestMethod.POST)
    public DataVo dispatch(@RequestBody TaskDispatchPo po){
        long total =  iWoTaskService.syncDispatch(po);
        DataVo vo =  DataVo.of();
        vo.setMessage("成功执行"+total+"个任务");
        return vo;
    }

}
